<template>
  <div class="app-container">
    <div class="app-top">
      <div class="input-line">
        <span class="input-label">操作名：</span>
        <el-input v-model="tableParam.actionTable" placeholder="请输入" style="width:210px" clearable />
      </div>
      <div class="input-line">
        <span class="input-label">备注：</span>
        <el-input v-model="tableParam.remark" placeholder="请输入" style="width:210px" clearable />
      </div>
      <div>
        <el-button type="primary" icon="el-icon-search" @click="tableParam.page=1,fetchData()">搜索</el-button>
      </div>
    </div>
    <div class="function" />
    <el-table v-loading="listLoading" :data="list" border :header-cell-style="{ background: '#f3f6f9' }" tooltip-effect="dark">
      <el-table-column align="center" label="ID" prop="id" width="40" />
      <el-table-column align="center" label="操作方法" prop="actionMethod" width="220" />
      <el-table-column align="center" label="操作表" prop="actionTable" width="160" />
      <el-table-column align="center" label="操作人" prop="createName" width="140" />
      <el-table-column align="center" label="请求参数" prop="params">
        <template slot-scope="scope">
          <el-tooltip effect="dark" placement="bottom">
            <div class="ellipsis2">{{ scope.row.params }}</div>
            <template #content>
              <div class="tooltip-content">{{ scope.row.params }}</div>
            </template>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column align="center" label="备注" prop="remark" width="100" />
      <el-table-column align="center" label="操作时间" prop="createTime" width="180" />
    </el-table>
    <div class="app-pagination">
      <el-pagination :current-page.sync="tableParam.page" :page-sizes="[10, 20, 30, 40]" :page-size="tableParam.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="sizeData" @current-change="fetchData()" />
      <el-button type="primary" size="mini" icon="el-icon-refresh" @click="fetchData()">刷新</el-button>
    </div>
  </div>
</template>

<script>
import { getLogs } from '@/api/logs'
export default {
  name: 'User',
  data() {
    return {
      list: null,
      listLoading: true,
      tableParam: {
        page: 1,
        pageSize: 10,
        actionTable: '',
        remark: ''
      },
      total: null
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    sizeData(e) {
      this.tableParam.page = 1
      this.tableParam.pageSize = e
      this.fetchData()
    },
    fetchData() {
      this.listLoading = true
      getLogs(this.tableParam).then(res => {
        this.list = res.data.row
        this.total = res.data.total
        this.listLoading = false
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.tooltip-content {
  max-width: 460px;
  line-height: 20px;
}
</style>
